package com.lengyu.vxminiprogram.iot.controller;


import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import com.lengyu.vxminiprogram.common.AuthUtil;
import com.lengyu.vxminiprogram.common.HttpResultDto;
import com.lengyu.vxminiprogram.iot.LengyuIotUtil;
import com.lengyu.vxminiprogram.security.rest.dto.JwtUser;
import com.lengyu.vxminiprogram.service.ITakePeopleService;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * <p>
 *  前端控制器
 * </p>
 *
 * @author liuyu
 * @since 2024-11-19
 */
@RestController
@RequestMapping("/tag")
public class TagController {
   @Autowired
   LengyuIotUtil lengyuIotUtil;

    @Autowired
    ITakePeopleService takePeopleService;

    @PostMapping(value="/getTagArray")
    public HttpResultDto<JSONArray> getTagArray(@RequestBody JSONObject paramsObj){
        String productId = paramsObj.getString("productId");
        if(StringUtils.isBlank(productId)){
            return HttpResultDto.success();
        }
        JSONObject params = new JSONObject();
        params.put("product_id",productId);
        JSONArray tagArray = lengyuIotUtil.getTagsArray(params);
        return HttpResultDto.success(tagArray);
    }

    @PostMapping(value="/getTagHistoryDataForEchartCompare")
    public HttpResultDto<JSONArray> getTagHistoryDataForEchartCompare(@RequestBody JSONObject paramsObj){

        JSONArray tagArray = lengyuIotUtil.getTagHistoryDataForEchartCompare(paramsObj);
        return HttpResultDto.success(tagArray);
    }


    @PostMapping(value="/getTagHistoryDataForEchart")
    public HttpResultDto<JSONObject> getTagHistoryDataForEchart(@RequestBody JSONObject paramsObj){

        JSONObject resultObj = lengyuIotUtil.getTagHistoryDataForEchart(paramsObj);
        return HttpResultDto.success(resultObj);
    }

}
